package mo.org.cm309.shoppingcart.service;

import mo.org.cm309.exception.AuthenticationException;
import mo.org.cm309.shoppingcart.entity.User;

public class LoginService {
	public User login(String email, String password) throws AuthenticationException{
		UserService userService = new UserService();
		User user = userService.gerUserByEmail(email);
		if (user == null)
			throw new AuthenticationException("This ID is not yet taken.");
		if (user.getPassword().equals(password))
			return user;
		throw new AuthenticationException("Invalid ID or password.");
	}
}
